package com.nsoft.thickclient.trackMove.search;

import java.awt.Component;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import com.nsoft.thickclient.controller.ScreenController;
import com.nsoft.thickclient.trackMove.account.SearchAccountAction;
import com.nsoft.thickclient.trackMove.intr.account.Account;
import com.nsoft.thickclient.trackMove.intr.party.Party;
import com.nsoft.thickclient.trackMove.intr.user.User;
import com.nsoft.thickclient.trackMove.intr.vehicle.Vehicle;
import com.nsoft.thickclient.trackMove.party.SearchPartyAction;
import com.nsoft.thickclient.trackMove.user.SearchUserAction;
import com.nsoft.thickclient.trackMove.vehicle.SearchVehicleAction;
import com.nsoft.thickclient.utils.IconFactory;

public class SearchToolViewController extends ScreenController {

	JPanel view;

	@Override
	public void close() {
		view = null;

	}

	@Override
	public String getScreenTitle() {
		return "Search tool";
	}

	@Override
	public JPanel getView() {
		return view;
	}

	@Override
	public void init() {
		view = new JPanel();
		JTabbedPane tabbedPane = new JTabbedPane();
		view.add(tabbedPane);
		tabbedPane.addTab("Search User", IconFactory.getImage(IconFactory.USER),getUserPanel());
		tabbedPane.addTab("Search Party", IconFactory.getImage(IconFactory.CLIENT),getPartyPanel());
		tabbedPane.addTab("Search Vehicle", IconFactory.getImage(IconFactory.TRUCK_2),getVehiclePanel());
		tabbedPane.addTab("Search Account", IconFactory.getImage(IconFactory.ACCOUNT),getAccountPanel());
	}

	private Component getAccountPanel() {
		SearchViewController<Account> controller = new SearchViewController<Account>(
				new SearchAccountAction(), "Search Account");
		controller.setApplicationController(getApplicationController());
		controller.init();
		return controller.getView();
	}

	private Component getVehiclePanel() {
		SearchViewController<Vehicle> controller = new SearchViewController<Vehicle>(
				new SearchVehicleAction(), "Search vehicle");
		controller.setApplicationController(getApplicationController());
		controller.init();
		return controller.getView();
	}

	private Component getPartyPanel() {
		SearchViewController<Party> controller = new SearchViewController<Party>(
				new SearchPartyAction(), "Search party");
		controller.setApplicationController(getApplicationController());
		controller.init();
		return controller.getView();
	}

	private Component getUserPanel() {
		SearchViewController<User> controller = new SearchViewController<User>(
				new SearchUserAction(), "Search user");
		controller.setApplicationController(getApplicationController());
		controller.init();
		return controller.getView();
	}

}
